import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;

public class ProblemWithoutMain {
    List<String> tempsGoal = new LinkedList<String>();
    List<String> tempsinit = new LinkedList<String>();
    BufferedReader br;
    String filePath = "C:\\test2.txt";
	 String line ;
	 String read; 
	  String objects[];
	  String init[];
	  String[] tempsgoals;
		String[]arrayinit = init() ;                 
		String[]arrayobj = object() ;   
	
	public ProblemWithoutMain(){
		line="";
		read = "";
		objects = new String [9];
		tempsgoals=new String [10];
	              

	}
	 public  String[] init(){
		 try {
		    	
		        br = new BufferedReader(new FileReader(filePath));
		        try {
		        	
		            while((line = br.readLine()) != null)
		            {
		            	
		        		read=br.readLine();

		            	String[] words = line.split(" ");
		            	 for (String word : words) {

		           	 if(word.equals("(:init")){
		           		 while((read = br.readLine()) != null &&!(read= br.readLine()).equals("(:goal")){
		            	  tempsinit.add(read);
		           		 }
		        
		          	
		          	  
		          	
		           	 }
		                
		            	 }
		           
		                }
		            
					init = tempsinit.toArray(new String[0]);

		            
		            br.close();
		           
		        } catch (IOException e) {
		            // TODO Auto-generated catch block
		            e.printStackTrace();
		        }
		    } catch (FileNotFoundException e) {
		        // TODO Auto-generated catch block
		        e.printStackTrace();

				System.out.println(init[6]);

		    }
		return init;
		  
	 }
	 public String[] object(){
		 try {
		     br = new BufferedReader(new FileReader(filePath));
		     try {
		         while((line = br.readLine()) != null)
		         {

		         	
		         	String[] words = line.split(" ");

		             for (String word : words) {
		               if (word.equals("(:objects") ) {

		             	  
		                String [] object = line.split(" ");
		                
		                 	 objects=object.clone();
		             //   System.out.println(object[i]+"#");

		                 
		                 
		               }
		              


		              
		               
		             }

		           
		         }
		      


		         
		         br.close();
		        
		     } catch (IOException e) {
		         // TODO Auto-generated catch block
		         e.printStackTrace();
		     }
		 } catch (FileNotFoundException e) {
		     // TODO Auto-generated catch block
		     e.printStackTrace();
		 }
		 return objects;
	 }
	 
	 public String[] goals(){
		 try {
		    	
		        br = new BufferedReader(new FileReader(filePath));
		        try {
		        	
		            while((line = br.readLine()) != null)
		            {
		            	
		        		read=br.readLine();

		            	String[] words = line.split("\\t+");
		            	

		            	 for (String word : words) {

		          	 if(word.equals("(and")){

		           		 while((read = br.readLine()) != null){
		            	  tempsGoal.add(read);
		           		 
		               	 }
		                	 
		         		 
		            
		             	 int i;
		             	
		          	 for( i=0  ; i<4 ;i++){
		        // String  []goal=tempsArray[i].split(" ");
		                 
		              //   System.out.println(goal[2]+"$");
		          	 }
		          	
		           	 }
		                
		            	 }
		           
		                }
			    	 tempsgoals = tempsGoal.toArray(new String[0]);


		            
		            br.close();
		           
		        } catch (IOException e) {
		            // TODO Auto-generated catch block
		            e.printStackTrace();
		        }
		    } catch (FileNotFoundException e) {
		        // TODO Auto-generated catch block
		        e.printStackTrace();

		    }
		    return tempsgoals;
		    
	 }
	 
	 public String index( int no){
		String index = arrayobj[no];
		return index;
		 
	 }
	public void display(){
		System.out.println("");
		
	}
	
}